# Contributor: Will Sinatra <wpsinatra@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libdrm
pkgver=2.4.112
pkgrel=0
pkgdesc="Userspace interface to kernel DRM services"
url="https://dri.freedesktop.org/"
arch="all"
# Requires a computer with gfx, no X running, build user in 'video' group..
options="!check"
license="MIT"
depends_dev="linux-headers"
makedepends="$depends_dev meson libpthread-stubs eudev-dev libpciaccess-dev xmlto"
checkdepends="cunit-dev bash"
subpackages="$pkgname-dev"
source="https://gitlab.freedesktop.org/mesa/drm/-/archive/libdrm-$pkgver/drm-libdrm-$pkgver.tar.gz"
builddir="$srcdir/drm-libdrm-$pkgver"

build() {
	abuild-meson \
		-Dfreedreno=true \
		-Dtegra=true \
		-Domap=true \
		-Dexynos=true \
		-Dvc4=true \
		-Detnaviv=true \
		-Dudev=true \
		. output
	meson compile ${JOBS:+-j ${JOBS}} -C output
}

check() {
	meson test -v -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

sha512sums="
32f9948369dcbac39e7d81a6045e06848d6f596409c68eea6e45af477bf0c519c61fcd67c92dfb20ba6fe554063596c6d59f72c23edd100685df49c984af3c9c  drm-libdrm-2.4.112.tar.gz
"
